package gui.data.D3;

import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.ButtonGroup;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

public class PolyhedronOutputGui extends JPanel{

	JTextField radiusInput, areaInput, bAreaInput, sAreaInput, heightInput, volumeInput, sideInput;
	JLabel radiusLbl, areaLbl, bAreaLbl, sAreaLbl, heightLbl, volumeLbl, sideLbl;
	int guide;

	public PolyhedronOutputGui(int guide, double radius, double side,
			double volume, double area, double sArea, double bArea,
			double height) {
		this.setLayout(new GridLayout(0, 2));
		this.setPreferredSize(new Dimension(500, 500));
		
		ButtonGroup group = new ButtonGroup();
		
		JRadioButton cylinder = new JRadioButton("Cylinder");
		JRadioButton prism = new JRadioButton("Prism");
		
		group.add(cylinder);
		group.add(prism);
		
		radiusLbl = new JLabel("Cylinder radius = ");
		areaLbl = new JLabel("Total area = ");
		sideLbl = new JLabel("Bottom edge length = ");
		sAreaLbl = new JLabel("Side area = ");
		bAreaLbl = new JLabel("Bottom area = ");
		volumeLbl = new JLabel("Volume = ");
		heightLbl = new JLabel("Height = ");
		
		radiusInput = new JTextField(radius == 0 ? "N/A":"" + radius);
		areaInput = new JTextField(area == 0 ? "N/A":"" + area);
		sideInput = new JTextField(side == 0 ? "N/A":"" + side);
		sAreaInput = new JTextField(sArea == 0 ? "N/A":"" + sArea);
		bAreaInput = new JTextField(bArea == 0 ? "N/A":"" + bArea);
		volumeInput = new JTextField(volume == 0 ? "N/A":"" + volume);
		heightInput = new JTextField(height == 0 ? "N/A":"" + height);
		
		this.add(cylinder);
		this.add(prism);		
		this.add(radiusLbl);
		this.add(radiusInput);
		this.add(sideLbl);
		this.add(sideInput);
		this.add(heightLbl);
		this.add(heightInput);
		this.add(areaLbl);
		this.add(areaInput);
		this.add(sAreaLbl);
		this.add(sAreaInput);
		this.add(bAreaLbl);
		this.add(bAreaInput);
		this.add(volumeLbl);
		this.add(volumeInput);
		this.add(new JLabel(""));
		
		if(guide == 1){
			cylinder.setSelected(true);
		}else if(guide == 2){
			prism.setSelected(true);
		}
		
		cylinder.setEnabled(false);
		prism.setEnabled(false);
		radiusInput.setEditable(false);
		areaInput.setEditable(false);
		sideInput.setEditable(false);
		sAreaInput.setEditable(false);
		bAreaInput.setEditable(false);
		volumeInput.setEditable(false);
		heightInput.setEditable(false);
	}
}
